//================v2要点总结===============
/**
 * 1. 利用 n & (n-1) 能够将最低位的1转化位0的特性
 */

/**
 * @param {number} n - a positive integer
 * @return {number}
 */
var hammingWeight = function (n) {
    let count = 0
    while (n) {
        n &= n - 1;
        count++
    }
    return count
};

// eslint-disable-next-line no-octal
console.log(hammingWeight(11));